<?php

namespace App\Http\Controllers\Admin\User;

use App\Services\Admin\User\UserService;
use Exception;
use Illuminate\Http\JsonResponse;

class UserController extends BaseUserController
{

    protected UserService $userService;

    /**
     * @throws Exception
     */
    public function __construct()
    {
        parent::__construct();
        $this->userService = $this->loadService('Admin\User\UserService');
    }

    /**
     * 用户列表
     * @return JsonResponse
     * @throws Exception
     */
    public function list(): JsonResponse
    {

        $list = $this->userService->list($this->params);

        return outputJsonResult($list);
    }

    /**
     * 邀请用户列表
     * @return JsonResponse
     * @throws Exception
     */
    public function inviteList(): JsonResponse
    {
        $rule = [
            'userId' => 'required|integer|min:1'
        ];

        if ($this->ruleCheck($rule)) {
            return outputJsonError();
        }

        $list = $this->userService->inviteList($this->params);
        return outputJsonResult($list);
    }

}
